﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.SoldierArchives.Model;
using Yipusoft.SoldierArchives.BLL;

public partial class Police_TranslateDocument_IntroFileList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ListPageContral1.SetFirstPage();
            bindGV(0);
        }
    }

    protected void ListPageContral1_PageSizeChange(int pageSize, int PageIndex)
    {
        bindGV(PageIndex);
    }

    void bindGV(int pageIndex)
    {

        string where = "";
        List<TranslateIntroFileInfo> list = TranslateIntrolFile.GetList(ListPageContral1.PageSize, pageIndex, where);
        ListPageContral1.ItemCount = TranslateIntrolFile.GetCount(where);
        UserGrid.DataSource = list;
        UserGrid.DataBind();
    }
    protected void UserGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label ID = (Label)e.Row.FindControl("ID");
            ID.Text = ((ListPageContral1.CurrentPageIndex * ListPageContral1.PageSize) + (e.Row.RowIndex + 1)).ToString();
            //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F5F5F5',this.style.fontWeight='';");
            //当鼠标离开的时候 将背景颜色还原的以前的颜色 
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");

        }
    }

    protected void UserGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "del")
        {
            if (TranslateIntrolFile.Delete(new Guid(e.CommandArgument.ToString())))
            {
                ListPageContral1.SetFirstPage();
                bindGV(0);
                Prompt.Text = "提示：删除一条记录！";
            }
        }
    }
}
